package com.carcenter.sms.controller;

import com.carcenter.common.result.enums.impl.BusinessCode;
import com.carcenter.sms.service.SmsService;
import com.carcenter.common.result.Result;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 短信服务
 */
@RestController
@RequestMapping("/sms")
public class SmsController {

    private final SmsService smsService;
    public SmsController(SmsService smsService) {
        this.smsService = smsService;
    }


    /**
     * 获取验证码
     *  发送短信-手机号      返回：发送成功/失败
     */
    @GetMapping("/{phone}")
    public Result sendCode(@PathVariable("phone")String phone) {
        Result result = smsService.sendCode(phone);
        return Result.ok(result);
    }
}